package com.zzb.projectfactory.framework.hbase;

import com.zzb.projectfactory.framework.param.service.SysParamService;
import com.zzb.projectfactory.framework.utils.SpringContextHolder;
import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.hbase.HBaseConfiguration;
import org.springframework.data.hadoop.hbase.HbaseTemplate;

/**
 *
 * Created by zhangzhenbin on 17-3-7.
 */
public class HbaseTemplateFactory {
    private static SysParamService paramService;
    static {
        paramService = SpringContextHolder.getBean("sysParamService");
    }
    public static HbaseTemplate build(){
        Configuration configuration = HBaseConfiguration.create();
        configuration.set("hbase.rootdir",paramService.getString("hbase.rootdir","hdfs://localhost:9090/hbase"));
        configuration.set("hbase.zookeeper.quorum",paramService.getString("hbase.zookeeper.quorum","localhost"));
        configuration.set("hbase.zookeeper.property.dataDir",paramService.getString("hbase.zookeeper.property.dataDir","/home/zhangzhenbin/Programs/zookeeper-3.4.9/zookeeper-data"));
        configuration.set("hbase.zookeeper.property.clientPort",paramService.getString("hbase.zookeeper.property.clientPort","2181"));
        return new HbaseTemplate(configuration);
    }
}
